package com.hongxun.modules.bss.service.impl;

//import java.util.UUID;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//import java.util.Map;
//
//import com.hongxun.modules.bss.dao.DMaterialBuyDao;
//import com.hongxun.modules.bss.entity.DMaterialBuyEntity;
//import com.hongxun.modules.bss.service.DMaterialBuyService;


import com.hongxun.modules.bss.dao.DMaterialBuyDao;
import com.hongxun.modules.bss.entity.DMaterialBuyEntity;
import com.hongxun.modules.bss.service.DMaterialBuyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service("dMaterialBuyService")
public class DMaterialBuyServiceImpl implements DMaterialBuyService {
    @Autowired
    private DMaterialBuyDao dMaterialBuyDao;

    @Override
    public DMaterialBuyEntity queryObject(String guid) {
        return dMaterialBuyDao.queryObject(guid);
    }

    @Override
    public List<DMaterialBuyEntity> queryList(Map<String, Object> map) {
        return dMaterialBuyDao.queryList(map);
    }

    @Override
    public List<DMaterialBuyEntity> queryAppList(Map<String, Object> map) {
        return dMaterialBuyDao.queryAppList(map);
    }

    @Override
    public List<DMaterialBuyEntity> queryListout(String pguid) {
        return dMaterialBuyDao.queryListout(pguid);
    }

    @Override
    public List<DMaterialBuyEntity> queryListhz(String pguid) {
        return dMaterialBuyDao.queryListhz(pguid);
    }


    @Override
    public int queryTotal(Map<String, Object> map) {
        return dMaterialBuyDao.queryTotal(map);
    }

    @Override
    public void save(DMaterialBuyEntity dMaterialBuy) {
        if (dMaterialBuy.getGuid() == null || dMaterialBuy.getGuid().equals("")) {

            dMaterialBuy.setGuid(UUID.randomUUID().toString());
        }
        dMaterialBuyDao.save(dMaterialBuy);
    }

    @Override
    public void update(DMaterialBuyEntity dMaterialBuy) {
        dMaterialBuyDao.update(dMaterialBuy);
    }

    @Override
    public void delete(String guid) {
        dMaterialBuyDao.delete(guid);
    }

    @Override
    public void deleteBatch(String[] guids) {
        dMaterialBuyDao.deleteBatch(guids);
    }

    @Override
    public List<DMaterialBuyEntity> queryListByDDguid(String[] guids) {
        return dMaterialBuyDao.queryListByDDguid(guids);
    }


    @Override
    public void insertOrReplaceOrDelete(List<DMaterialBuyEntity> entities) {
        for (DMaterialBuyEntity d : entities) {
            if (d.getMBDatastate().equals("删除")) {
                dMaterialBuyDao.delete(d.getGuid());
            } else {
                DMaterialBuyEntity dMaterialBuyEntity = dMaterialBuyDao.queryObject(d.getGuid());
                if (dMaterialBuyEntity == null) {
                    dMaterialBuyDao.save(d);
                } else {
                    dMaterialBuyDao.update(d);
                }
            }
        }
    }
}
